package view;

import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Label;
import java.awt.Point;
import java.awt.event.MouseAdapter;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import data.Images;

import main.KeyDefinitions;

public class EditControlView{
	/*****
	 * LABELS
	 */
	private EditControlLabel lblCycling;
	private EditControlLabel lblModePrev;
	private EditControlLabel lblModeNext;
	private EditControlLabel lblTypePrev;
	private EditControlLabel lblTypeNext;
	private EditControlLabel lblInstancePrev;
	private EditControlLabel lblInstanceNext;
	private EditControlLabel lblCommandPrev;
	private EditControlLabel lblCommandNext;
	
	private EditControlLabel lblDirection;
	private EditControlLabel lblNorth;
	private EditControlLabel lblNorthEast;
	private EditControlLabel lblNorthWest;
	private EditControlLabel lblSouth;
	private EditControlLabel lblSouthEast;
	private EditControlLabel lblSouthWest;
	
	private EditControlLabel lblSelection;
	private EditControlLabel lblSelect1;
	private EditControlLabel lblSelect2;
	private EditControlLabel lblSelect3;
	private EditControlLabel lblSelect4;
	private EditControlLabel lblSelect5;
	private EditControlLabel lblSelect6;
	private EditControlLabel lblSelect7;
	private EditControlLabel lblSelect8;
	private EditControlLabel lblSelect9;
	private EditControlLabel lblSelect0;
	
	private EditControlLabel lblOther;
	private EditControlLabel lblFocus;
	private EditControlLabel lblIssue;
	private EditControlLabel lblPause;
	private EditControlLabel lblTab;
	private EditControlLabel lblCreateRally;
	private EditControlLabel lblCancel;
	private EditControlLabel lblSwitchView;
	
	/*****
	 * BUTTONS
	 */
	private EditControlButton btnModePrev;
	private EditControlButton btnModeNext;
	private EditControlButton btnTypePrev;
	private EditControlButton btnTypeNext;
	private EditControlButton btnInstancePrev;
	private EditControlButton btnInstanceNext;
	private EditControlButton btnCommandPrev;
	private EditControlButton btnCommandNext;
	
	private EditControlButton btnNorth;
	private EditControlButton btnNorthEast;
	private EditControlButton btnNorthWest;
	private EditControlButton btnSouth;
	private EditControlButton btnSouthEast;
	private EditControlButton btnSouthWest;
	
	private EditControlButton btnSelect1;
	private EditControlButton btnSelect2;
	private EditControlButton btnSelect3;
	private EditControlButton btnSelect4;
	private EditControlButton btnSelect5;
	private EditControlButton btnSelect6;
	private EditControlButton btnSelect7;
	private EditControlButton btnSelect8;
	private EditControlButton btnSelect9;
	private EditControlButton btnSelect0;
	
	private EditControlButton btnFocus;
	private EditControlButton btnIssue;
	private EditControlButton btnPause;
	private EditControlButton btnTab;
	private EditControlButton btnCreateRally;
	private EditControlButton btnCancel;
	private EditControlButton btnSwitchView;
	
	private EditControlButton btnDefaults;
	private EditControlButton btnLoad;
	private EditControlButton btnSave;
	
	
	JLayeredPane layeredPane;
	JPanel top;
	JFrame frame;
	Images images;
	ImageIcon lblImage;
	KeyDefinitions keyDefs;
	public EditControlView(KeyDefinitions _keyDefs){
		keyDefs = _keyDefs;
		initComps();
		frame.setResizable(false);
	}
	private void initComps(){
		Dimension screensize = new Dimension(435,550);
		layeredPane = new JLayeredPane();
		layeredPane.setSize(screensize);
		top = new JPanel();
		top.setMinimumSize(screensize);
		top.setSize(screensize);
		
		images = new Images();
		GridBagConstraints gbc = new GridBagConstraints(); 
		
		frame = new JFrame();
		frame.setTitle("AGRTS - Edit Control View");
		frame.setVisible(true);
		frame.setSize(screensize);
		layeredPane.add(top,0);
		top.setBackground(new Color(157,157,157));
		frame.setContentPane(layeredPane);
		
		GridBagLayout gblo = new GridBagLayout();
		top.setLayout(gblo);
		
		images = new Images();
		lblImage = new ImageIcon(images.getImage("EditControlLabel"));
		
		/**
		 * Initialize Labels
		 */
		lblCycling = new EditControlLabel("Cycling");
		lblModePrev = new EditControlLabel("ModePrev");
		lblModeNext = new EditControlLabel("ModeNext");
		lblTypePrev = new EditControlLabel("TypePrev");
		lblTypeNext = new EditControlLabel("TypeNext");
		lblInstancePrev = new EditControlLabel("InstancePrev");
		lblInstanceNext = new EditControlLabel("InstanceNext");
		lblCommandPrev = new EditControlLabel("CommandPrev");
		lblCommandNext = new EditControlLabel("CommandNext");
		
		lblDirection = new EditControlLabel("Direction");
		lblNorth = new EditControlLabel("North");
		lblNorthEast = new EditControlLabel("NorthEast");
		lblNorthWest = new EditControlLabel("NorthWest");
		lblSouth = new EditControlLabel("South");
		lblSouthEast = new EditControlLabel("SouthEast");
		lblSouthWest = new EditControlLabel("SouthWest");
		
		lblSelection = new EditControlLabel("Selection");
		lblSelect1 = new EditControlLabel("Select1");
		lblSelect2 = new EditControlLabel("Select2");
		lblSelect3 = new EditControlLabel("Select3");
		lblSelect4 = new EditControlLabel("Select4");
		lblSelect5 = new EditControlLabel("Select5");
		lblSelect6 = new EditControlLabel("Select6");
		lblSelect7 = new EditControlLabel("Select7");
		lblSelect8 = new EditControlLabel("Select8");
		lblSelect9 = new EditControlLabel("Select9");
		lblSelect0 = new EditControlLabel("Select0");
		
		lblOther = new EditControlLabel("Other");
		lblFocus = new EditControlLabel("Focus");
		lblIssue = new EditControlLabel("Issue");
		lblPause = new EditControlLabel("Pause");
		lblTab = new EditControlLabel("Tab");
		lblCreateRally = new EditControlLabel("CreateRally");
		lblCancel = new EditControlLabel("Cancel");
		lblSwitchView = new EditControlLabel("SwitchView"); 
		
		/***
		 * Add Labels to content pane
		 */
		//lblCycling
		gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblCycling, gbc);
		//lblModePrev
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblModePrev, gbc);
		//lblModeNext
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblModeNext, gbc);
		//lblTypePrev
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblTypePrev, gbc);
		//lblTypeNext
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblTypeNext, gbc);
		//lblInstancePrev
        gbc.gridx = 0;
        gbc.gridy = 5;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblInstancePrev, gbc);
		//lblInstanceNext
        gbc.gridx = 0;
        gbc.gridy = 6;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblInstanceNext, gbc);
		//lblCommandPrev
        gbc.gridx = 0;
        gbc.gridy = 7;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblCommandPrev, gbc);
		//lblCommandNext
        gbc.gridx = 0;
        gbc.gridy = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblCommandNext, gbc);
		
		//lblDirection
        gbc.gridx = 0;
        gbc.gridy = 9;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblDirection, gbc);
		//lblNorth
        gbc.gridx = 0;
        gbc.gridy = 10;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblNorth, gbc);
		//lblNorthEast
        gbc.gridx = 0;
        gbc.gridy = 11;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblNorthEast, gbc);
		//lblNorthWest
        gbc.gridx = 0;
        gbc.gridy = 12;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblNorthWest, gbc);
		//lblSouth
        gbc.gridx = 0;
        gbc.gridy = 13;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSouth, gbc);
		//lblSouthEast
        gbc.gridx = 0;
        gbc.gridy = 14;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSouthEast, gbc);
		//lblSouthWest
        gbc.gridx = 0;
        gbc.gridy = 15;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSouthWest, gbc);
		
		//lblSelection
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelection, gbc);
		//lblSelect1
        gbc.gridx = 2;
        gbc.gridy = 1;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect1, gbc);
		//lblSelect2
        gbc.gridx = 2;
        gbc.gridy = 2;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect2, gbc);
		//lblSelect3
        gbc.gridx = 2;
        gbc.gridy = 3;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect3, gbc);
		//lblSelect4
        gbc.gridx = 2;
        gbc.gridy = 4;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect4, gbc);
		//lblSelect5
        gbc.gridx = 2;
        gbc.gridy = 5;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect5, gbc);
		//lblSelect6
        gbc.gridx = 2;
        gbc.gridy = 6;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect6, gbc);
		//lblSelect7
        gbc.gridx = 2;
        gbc.gridy = 7;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect7, gbc);
		//lblSelect8
        gbc.gridx = 2;
        gbc.gridy = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect8, gbc);
		//lblSelect9
        gbc.gridx = 2;
        gbc.gridy = 9;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect9, gbc);
		//lblSelect0
        gbc.gridx = 2;
        gbc.gridy = 10;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSelect0, gbc);
		
		//lblOther
        gbc.gridx = 2;
        gbc.gridy = 11;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblOther, gbc);
		//lblFocus
        gbc.gridx = 2;
        gbc.gridy = 12;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblFocus, gbc);
		//lblIssue
        gbc.gridx = 2;
        gbc.gridy = 13;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblIssue, gbc);
		//lblPause
        gbc.gridx = 2;
        gbc.gridy = 14;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblPause, gbc);
      //lblTab
        gbc.gridx = 2;
        gbc.gridy = 15;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblTab, gbc);
      //lblCreateRally
        gbc.gridx = 2;
        gbc.gridy = 16;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblCreateRally, gbc);
      //lblCancel
        gbc.gridx = 2;
        gbc.gridy = 17;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblCancel, gbc);
      //lblSwitchView
        gbc.gridx = 2;
        gbc.gridy = 18;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(lblSwitchView, gbc);
        
        
		/***
		 * Initialize Buttons
		 */
		btnModePrev = new EditControlButton(keyDefs.toStringModePrev());
		btnModeNext = new EditControlButton(keyDefs.toStringModeNext());
		btnTypePrev = new EditControlButton(keyDefs.toStringTypePrev());
		btnTypeNext = new EditControlButton(keyDefs.toStringTypeNext());
		btnInstancePrev = new EditControlButton(keyDefs.toStringInstancePrev());
		btnInstanceNext = new EditControlButton(keyDefs.toStringInstanceNext());
		btnCommandPrev = new EditControlButton(keyDefs.toStringCommandPrev());
		btnCommandNext = new EditControlButton(keyDefs.toStringCommandNext());
		
		btnNorth = new EditControlButton(keyDefs.toStringNorth());
		btnNorthEast = new EditControlButton(keyDefs.toStringNorthEast());
		btnNorthWest = new EditControlButton(keyDefs.toStringNorthWest());
		btnSouth = new EditControlButton(keyDefs.toStringSouth());
		btnSouthEast = new EditControlButton(keyDefs.toStringSouthEast());
		btnSouthWest = new EditControlButton(keyDefs.toStringSouthWest());
		
		btnSelect1 = new EditControlButton(keyDefs.toStringSelect1());
		btnSelect2 = new EditControlButton(keyDefs.toStringSelect2());
		btnSelect3 = new EditControlButton(keyDefs.toStringSelect3());
		btnSelect4 = new EditControlButton(keyDefs.toStringSelect4());
		btnSelect5 = new EditControlButton(keyDefs.toStringSelect5());
		btnSelect6 = new EditControlButton(keyDefs.toStringSelect6());
		btnSelect7 = new EditControlButton(keyDefs.toStringSelect7());
		btnSelect8 = new EditControlButton(keyDefs.toStringSelect8());
		btnSelect9 = new EditControlButton(keyDefs.toStringSelect9());
		btnSelect0 = new EditControlButton(keyDefs.toStringSelect0());
		
		btnFocus = new EditControlButton(keyDefs.toStringFocus());
		btnIssue = new EditControlButton(keyDefs.toStringIssue());
		btnPause = new EditControlButton(keyDefs.toStringPause());
		btnTab = new EditControlButton(keyDefs.toStringTab());
		btnCreateRally = new EditControlButton(keyDefs.toStringCreateRally());
		btnCancel = new EditControlButton(keyDefs.toStringCancel());
		btnSwitchView = new EditControlButton(keyDefs.toStringSwitchView());
		
		btnDefaults = new EditControlButton("Defaults");
		btnLoad = new EditControlButton("Load");
		btnSave = new EditControlButton("Save");
		
		/**update button text
		 * 
		 */
		updateButtonText();
		/** add buttons to content pane
		 * 
		 */
		//btnModePrev
		gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnModePrev, gbc);
		//btnModeNext
		gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnModeNext, gbc);
		//btnTypePrev
		gbc.gridx = 1;
        gbc.gridy = 3;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnTypePrev, gbc);
		//btnTypeNext
		gbc.gridx = 1;
        gbc.gridy = 4;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnTypeNext, gbc);
		//btnInstancePrev
		gbc.gridx = 1;
        gbc.gridy = 5;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnInstancePrev, gbc);
		//btnInstanceNext
		gbc.gridx = 1;
        gbc.gridy = 6;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnInstanceNext, gbc);
		//btnCommandPrev
		gbc.gridx = 1;
        gbc.gridy = 7;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnCommandPrev, gbc);
		//btnCommandNext
		gbc.gridx = 1;
        gbc.gridy = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnCommandNext, gbc);
		
		//btnNorth
		gbc.gridx = 1;
        gbc.gridy = 10;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnNorth, gbc);
		//btnNorthEast
		gbc.gridx = 1;
        gbc.gridy = 11;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnNorthEast, gbc);
		//btnNorthWest
		gbc.gridx = 1;
        gbc.gridy = 12;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnNorthWest, gbc);
		//btnSouth
		gbc.gridx = 1;
        gbc.gridy = 13;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSouth, gbc);
		//btnSouthEast
		gbc.gridx = 1;
        gbc.gridy = 14;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSouthEast, gbc);
		//btnSouthWest
		gbc.gridx = 1;
        gbc.gridy = 15;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSouthWest, gbc);
		
		//btnSelect1
		gbc.gridx = 3;
        gbc.gridy = 1;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect1, gbc);
		//btnSelect2
		gbc.gridx = 3;
        gbc.gridy = 2;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect2, gbc);
		//btnSelect3
		gbc.gridx = 3;
        gbc.gridy = 3;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect3, gbc);
		//btnSelect4
		gbc.gridx = 3;
        gbc.gridy = 4;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect4, gbc);
		//btnSelect5
		gbc.gridx = 3;
        gbc.gridy = 5;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect5, gbc);
		//btnSelect6
		gbc.gridx = 3;
        gbc.gridy = 6;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect6, gbc);
		//btnSelect7
		gbc.gridx = 3;
        gbc.gridy = 7;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect7, gbc);
		//btnSelect8
		gbc.gridx = 3;
        gbc.gridy = 8;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect8, gbc);
		//btnSelect9
		gbc.gridx = 3;
        gbc.gridy = 9;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect9, gbc);
		//btnSelect0
		gbc.gridx = 3;
        gbc.gridy = 10;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSelect0, gbc);
		
		//btnFocus
		gbc.gridx = 3;
        gbc.gridy = 12;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnFocus, gbc);
		//btnIssue
		gbc.gridx = 3;
        gbc.gridy = 13;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnIssue, gbc);
		//btnPause
		gbc.gridx = 3;
        gbc.gridy = 14;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnPause, gbc);
      //btnTab
		gbc.gridx = 3;
        gbc.gridy = 15;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnTab, gbc);
      //btnCreateRally
		gbc.gridx = 3;
        gbc.gridy = 16;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnCreateRally, gbc);
      //btnCancel
		gbc.gridx = 3;
        gbc.gridy = 17;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnCancel, gbc);
      //btnSwitchView
		gbc.gridx = 3;
        gbc.gridy = 18;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnSwitchView, gbc);
        
        //btnDefaults
        gbc.gridx = 0;
        gbc.gridy = 17;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        top.add(btnDefaults,gbc);
        //btnSave
        gbc.gridx = 1;
        gbc.gridy = 17;
        gbc.fill = java.awt.GridBagConstraints.CENTER;
        top.add(btnSave,gbc);
        //btnLoad
        gbc.gridx = 1;
        gbc.gridy = 18;
        gbc.fill = java.awt.GridBagConstraints.CENTER;
        top.add(btnLoad,gbc);
        
        /**
         * btn Mouse Listeners
         */
        //btnModePrev
        btnModePrev.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
                promptKeyChange("modePrev");
            }
        });
        //btnModeNext
        btnModeNext.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("modeNext");
            }
        });
        //btnTypePrev
        btnTypePrev.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("typePrev");
            }
        });
		//btnTypeNext
        btnTypeNext.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("typeNext");
            }
        });
		//btnInstancePrev
        btnInstancePrev.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("instancePrev");
            }
        });
		//btnInstanceNext
        btnInstanceNext.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("instanceNext");
            }
        });
		//btnCommandPrev
        btnCommandPrev.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("commandPrev");
            }
        });
		//btnCommandNext
        btnCommandNext.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("commandNext");
            }
        });
		
		//btnNorth
        btnNorth.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("North");
            }
        });
		//btnNorthEast
        btnNorthEast.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("NorthEast");
            }
        });
		//btnNorthWest
        btnNorthWest.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("NorthWest");
            }
        });
		//btnSouth
        btnSouth.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("South");
            }
        });
		//btnSouthEast
        btnSouthEast.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("SouthEast");
            }
        });
		//btnSouthWest
        btnSouthWest.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("SouthWest");
            }
        });
		
		//btnSelect1
        btnSelect1.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select1");
            }
        });
		//btnSelect2
        btnSelect2.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select2");
            }
        });
		//btnSelect3
        btnSelect3.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select3");
            }
        });
		//btnSelect4
        btnSelect4.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select4");
            }
        });
		//btnSelect5
        btnSelect5.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select5");
            }
        });
		//btnSelect6
        btnSelect6.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select6");
            }
        });
		//btnSelect7
        btnSelect7.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select7");
            }
        });
		//btnSelect8
        btnSelect8.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select8");
            }
        });
		//btnSelect9
        btnSelect9.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select9");
            }
        });
		//btnSelect0
        btnSelect0.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Select0");
            }
        });
		
		//btnFocus
        btnFocus.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Focus");
            }
        });
		//btnIssue
        btnIssue.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Issue");
            }
        });
		//btnPause
        btnPause.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Pause");
            }
        });
      //btnTab
        btnTab.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Tab");
            }
        });
      //btnCreateRally
        btnCreateRally.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("createRally");
            }
        });
      //btnCancel
        btnCancel.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("Cancel");
            }
        });
      //btnSwitchView
        btnSwitchView.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		promptKeyChange("switchView");
            }
        });
        //btnDefaults
        btnDefaults.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		keyDefs.restoreDefault();
        		updateButtonText();
            }
        });
        //btnLoad
        btnLoad.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		loadKeyDefs();
            }
        });
        //btnSave
        btnSave.addMouseListener(new MouseAdapter(){
        	public void mouseClicked(java.awt.event.MouseEvent evt) {
        		saveKeyDefs();;
            }
        });
	}
	public void updateButtonText(){
		btnModePrev.btnText = keyDefs.toStringModePrev();
		btnModePrev.repaint();
		btnModeNext.btnText = keyDefs.toStringModeNext();
		btnModeNext.repaint();
		btnTypePrev.btnText =(keyDefs.toStringTypePrev());
		btnTypePrev.repaint();
		btnTypeNext.btnText =(keyDefs.toStringTypeNext());
		btnTypeNext.repaint();
		btnInstancePrev.btnText =(keyDefs.toStringInstancePrev());
		btnInstancePrev.repaint();
		btnInstanceNext.btnText =(keyDefs.toStringInstanceNext());
		btnInstanceNext.repaint();
		btnCommandPrev.btnText =(keyDefs.toStringCommandPrev());
		btnCommandPrev.repaint();
		btnCommandNext.btnText =(keyDefs.toStringCommandNext());
		btnCommandNext.repaint();
		
		btnNorth.btnText =(keyDefs.toStringNorth());
		btnNorth.repaint();
		btnNorthEast.btnText =(keyDefs.toStringNorthEast());
		btnNorthEast.repaint();
		btnNorthWest.btnText =(keyDefs.toStringNorthWest());
		btnNorthWest.repaint();
		btnSouth.btnText =(keyDefs.toStringSouth());
		btnSouth.repaint();
		btnSouthEast.btnText =(keyDefs.toStringSouthEast());
		btnSouthEast.repaint();
		btnSouthWest.btnText =(keyDefs.toStringSouthWest());
		btnSouthWest.repaint();
		
		btnSelect1.btnText =(keyDefs.toStringSelect1());
		btnSelect1.repaint();
		btnSelect2.btnText =(keyDefs.toStringSelect2());
		btnSelect2.repaint();
		btnSelect3.btnText =(keyDefs.toStringSelect3());
		btnSelect3.repaint();
		btnSelect4.btnText =(keyDefs.toStringSelect4());
		btnSelect4.repaint();
		btnSelect5.btnText =(keyDefs.toStringSelect5());
		btnSelect5.repaint();
		btnSelect6.btnText =(keyDefs.toStringSelect6());
		btnSelect6.repaint();
		btnSelect7.btnText =(keyDefs.toStringSelect7());
		btnSelect7.repaint();
		btnSelect8.btnText =(keyDefs.toStringSelect8());
		btnSelect8.repaint();
		btnSelect9.btnText =(keyDefs.toStringSelect9());
		btnSelect9.repaint();
		btnSelect0.btnText =(keyDefs.toStringSelect0());
		btnSelect0.repaint();
		
		btnFocus.btnText =(keyDefs.toStringFocus());
		btnFocus.repaint();
		btnIssue.btnText =(keyDefs.toStringIssue());
		btnIssue.repaint();
		btnPause.btnText =(keyDefs.toStringPause());
		btnPause.repaint();
		btnTab.btnText =(keyDefs.toStringTab());
		btnTab.repaint();
		btnCreateRally.btnText =(keyDefs.toStringCreateRally());
		btnCreateRally.repaint();
		btnCancel.btnText =(keyDefs.toStringCancel());
		btnCancel.repaint();
		btnSwitchView.btnText =(keyDefs.toStringSwitchView());
		btnSwitchView.repaint();
	}
	private void promptKeyChange(String command){
		EditControlPrompt ecp = new EditControlPrompt(command,keyDefs,this);
	}
	private void loadKeyDefs(){
		FileLoad fl = new FileLoad(keyDefs,this);
	}
	private void saveKeyDefs(){
		FileSave fl = new FileSave(keyDefs,this);
	}
	
}
